<template>
  <el-dialog :title="title" :visible.sync="show" width="600px" append-to-body :before-close="close">
    <el-form ref="form" :model="form" :rules="rules" label-width="100px" class="demo-ruleForm">
      <el-form-item label="订购人真实姓名" prop="name">
        <el-input v-model="customsDeclareInfo.buyerName" />
      </el-form-item>
      <el-form-item label="订购人身份证号码" prop="IDNo">
        <el-input v-model="customsDeclareInfo.buyerIDNo" />
      </el-form-item>
      <el-form-item label="支付单号" prop="id">
        <el-input v-model="customsDeclareInfo.payOrderId" />
      </el-form-item>

      <el-row style="top: 30px;margin-bottom: 30px;text-align:center;">
        <el-col :span="24">
          <el-button type="primary" size="medium" @click="submitForm('form')">{{ title }}</el-button>
          <el-button size="medium" @click="close()">取消</el-button>
        </el-col>
      </el-row>
    </el-form>
  </el-dialog>
</template>
<style scoped>
.el-form-item__label {
  width: 9.375rem !important;
}
.el-form-item__content {
  margin-left: 9.375rem !important;
}
.demo-table-expand {
  font-size: 0;
}

.demo-table-expand label {
  width: 40%;
}

.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}

.el-dialog:not(.is-fullscreen) {
  margin-top: 6vh !important;
  margin-bottom: 6vh !important;
}
</style>
<script>
import { modifyInfo } from '@/api/externalGoods'
export default {
  name: 'OrderDetails',
  props: {
    form: {
      type: Object,
      default() {
        return {}
      }
    },
    show: {
      type: Boolean
    },
    title: {
      type: String
    }
  },
  data() {
    return {
      customsDeclareInfo: {},
      rules: {
        name: [
          { required: true, message: '请输入订购人真实姓名', trigger: 'blur' }
        ],
        IDNo: [
          { required: true, message: '请输入订购人身份证号码', trigger: 'blur' }
        ],
        id: [
          { required: true, message: '请输入支付单号', trigger: 'blur' }
        ]
      }
    }
  },
  watch: {
    show(val) {
      if (val) {
        console.log(this.form)
        this.customsDeclareInfo = this.form.customsDeclareInfo
      }
    }
  },
  created() {
  },
  methods: {
    submitForm(row) {
      const that = this
      console.log(this.form.id)
      modifyInfo(this.form.id, this.customsDeclareInfo).then(response => {
        console.log(response)
        if (response.code === 10000) {
          that.$message.success(response.message)
          that.close()
        } else {
          that.$message.error(response.message)
        }
      })
    },
    close() {
      this.$emit('update:show', false)
    }
  }
}
</script>
